this._saveTimer.endWaiting();
this.textDoc.editor.off('changes', this._closures.cm_changes); this.textDoc.editor.off('cursorActivity', this._closures.cm_cursorActivity); this.textDoc.editor.off('viewportChange', this._closures.cm_viewportChange); var editor = this.textDoc.editor;
this.textDoc.editor = null;
CodeMirrorDocHandler.codeMirrorEditorPools[this.moduleName || ''];
private _docChanges(docChanges: CodeMirror.EditorChange[]) { if (this.textDoc.onChanges)
this.textDoc.onChanges(docChanges);
this._scrollerModel.docChanges(docChanges);
this._saveTimer.interval = (this.moduleObj && this.moduleObj.saveDelay) || saveDelay;
var latestChange = docChanges[docChanges.length - 1];
if (latestChange.text && latestChange.text.length) { var latestChangeText = latestChange.text[latestChange.text.length - 1];
var triggers = this.moduleObj && this.moduleObj.completionTriggers ?
this.moduleObj.completionTriggers :
if (ko.utils.arrayIndexOf(triggers, latestChangeText.charAt(latestChangeText.length - 1)) >= 0) { this._triggerCompletion();
private _triggerCompletion() { if (this.textDoc.onCompletion) { var asyncContinueCompletion = (cm, callback, options) => this._continueCompletion(callback);
(<any>asyncContinueCompletion).async = true;
this.textDoc.editor.showHint({ hint: asyncContinueCompletion,
private _continueCompletion(callback: (result: CodeMirror.showHint.CompletionResult) => void) { this.textDoc.onCompletion(callback);
private _cursorActivity() { if (this.textDoc.onCursorMoved) { var cursorPos = this.textDoc.doc.getCursor();
this.textDoc.onCursorMoved(cursorPos);
private _viewportChange(from: number, to: number) { if (this.textDoc.onViewportMoved) { this.textDoc.onViewportMoved(from, to);
this._scrollerModel.viewportMoved(from, to);
this.storage.write(this.textDoc.doc.getValue());